###FIRST RUN Study 2 Data Code.R###

####TABLE 4####
table4 <- matrix(NA,4,3)

table4[1,1] <- mean(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0 & study2_mi$PARTISAN == 1],na.rm=T)
table4[1,2] <- mean(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1 & study2_mi$PARTISAN == 1],na.rm=T)
table4[1,3] <- table4[1,2] - table4[1,1]
table4[2,1] <- sum(table(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0 & study2_mi$PARTISAN == 1]))
table4[2,2] <- sum(table(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1 & study2_mi$PARTISAN == 1]))
table4[2,3] <- as.numeric(t.test(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1 & study2_mi$PARTISAN == 1],study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0 & study2_mi$PARTISAN == 1])[3])

table4[3,1] <- mean(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0 & study2_mi$PARTISAN < 3],na.rm=T)
table4[3,2] <- mean(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1 & study2_mi$PARTISAN < 3],na.rm=T)
table4[3,3] <- table4[3,2]  - table4[3,1]
table4[4,1] <- sum(table(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0 & study2_mi$PARTISAN < 3]))
table4[4,2] <- sum(table(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1 & study2_mi$PARTISAN < 3]))
table4[4,3] <- as.numeric(t.test(study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==1 & study2_mi$PARTISAN < 3],study2_mi$PROP2_SQ[study2_mi$PROP2_TREAT==0 & study2_mi$PARTISAN < 3])[3])
###############
